<?php

/**
 * Удаляет файл.
 *
 */
class Learning_Backend_Aids_DeleteFile extends Kernel_Filter
{
    
    public function process() 
    {
        $this->_delete();
        database::delete('learning_aids_files', (int)Application::getRequest()->get('file'));
        $this->_location($_SERVER['HTTP_REFERER']);
    }
    
    private function _delete() 
    {
        $query = '
            SELECT 
                   `file` 
              FROM 
                   `learning_aids_files` 
             WHERE 
                   `id` = ' . Application::getRequest()->get('file');
        @unlink(SITE_ROOT . '/' . Kernel_Config::get('learning', 'UPLOAD_DIR') . database::fetchOne($query));
    }
    
}
